package dbc.comm;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DatabaseConnection {
	private static final String DBDRIVER="org.gjt.mm.mysql.Driver";
	private static final String DBURL="jdbc:mysql://localhost:3306/hw";
	private static final String DBUSER="root";
	private static final String DBPASSWORD="123456";
	private Connection conn=null;
	public DatabaseConnection() throws Exception{
		Class.forName(DBDRIVER);
		this.conn=DriverManager.getConnection(DBURL, DBUSER, DBPASSWORD);
	}
	public Connection getConnection(){
		return this.conn;
	}
	public void close() throws SQLException{
		if(this.conn!=null){
			this.conn.close();
		}
	}
}
